<?php

namespace app\api\controller\user;

use app\api\services\user\JoinOnboardingServices;
use app\api\validate\JoinOnboardingValidate;
use app\common\controller\Api;

/**
 * 骑手入驻
 */
class JoinOnboarding extends Api
{
    protected $noNeedRight = '*';

    /**
     * 入驻
     * @return void
     * @throws \think\Exception
     */
    public function enter()
    {
        $params = input();
        (new JoinOnboardingValidate())->goCheck();
        $params['user_id'] = $this->auth->id;
        JoinOnboardingServices::getInstance()->enter($params);
        $this->success('提交成功，等待审核');
    }

    /**
     * 回显入驻信息
     * @return void
     */
    public function getJoinOnboarding()
    {
        $userid = $this->auth->id;
        $joinMerchant = JoinOnboardingServices::getInstance()->getJoinMerchant($userid);
        // 装饰选择的技能
        JoinOnboardingServices::getInstance()->decorationSkillChecked($joinMerchant);
        JoinOnboardingServices::decorationImgPrefixUrl($joinMerchant, ['id_card_front_image', 'id_card_back_image']);
        $this->success('获取成功', $joinMerchant);
    }
}